package zy.ejb2;

import java.util.Properties;

import javax.naming.InitialContext;
import javax.rmi.PortableRemoteObject;

import zy.ejb.EJB3Factory;

public class EJB2Factory {
	public static void demo_EJB2() {

		try {

			InitialContext context = new InitialContext();
			Object remoteObj = context
					.lookup("java:global/ear1/ejb1/helloEJB!zy.ejb2.HelloWorldRemoteHome");
			HelloWorldRemoteHome remoteHome = (HelloWorldRemoteHome) PortableRemoteObject
					.narrow(remoteObj, HelloWorldRemoteHome.class);
			HelloWorldRemoteEJBObj remote = (HelloWorldRemoteEJBObj) remoteHome
					.create();
			System.out.println(remote.sayHello_Remote());

			Object localObj = context
					.lookup("java:global/ear1/ejb1/helloEJB!zy.ejb2.HelloWorldLocalHome");
			HelloWorldLocalHome localHome = (HelloWorldLocalHome) PortableRemoteObject
					.narrow(localObj, HelloWorldLocalHome.class);
			HelloWorldLocalEJBObj local = (HelloWorldLocalEJBObj) localHome
					.create();

			System.out.println(local.sayHello_Local());
		} catch (Exception ex) {
			ex.printStackTrace();

		}
	}

}
